Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unreliable ASTJson tests #12696

Merged
merged 7 commits into from
Mar 14, 2022
Merged

Fix unreliable ASTJson tests #12696

merged 7 commits into from
Mar 14, 2022

Conversation

wechman
Copy link
Collaborator

@wechman wechman commented Feb 17, 2022

fixes #12621

ASTJson test variants are generated based on JSON file availability. Then they are validated against "failAfter" marker in a solidity source file. If the "failAfter" marker is not here all generated test variants are accepted. Otherwise, compiler state in test variant is compared against "failAfter" marker. If it is later in compilation steps order, the test is interrupted with exception.

@wechman wechman force-pushed the unreliableAstJsonTests branch from babfb44 to 2ac041e Compare February 18, 2022 08:15
@wechman wechman dismissed a stale review via ff44c8a February 21, 2022 11:26
@wechman wechman force-pushed the unreliableAstJsonTests branch from 2ac041e to ff44c8a Compare February 21, 2022 11:26
test/libsolidity/ASTJSONTest.cpp Outdated Show resolved Hide resolved
Copy link
Member

@cameel cameel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some remarks but overall I like the direction it's going in.

test/libsolidity/ASTJSONTest.cpp Outdated Show resolved Hide resolved
test/libsolidity/ASTJSONTest.cpp Outdated Show resolved Hide resolved
test/libsolidity/ASTJSONTest.cpp Outdated Show resolved Hide resolved
test/libsolidity/ASTJSONTest.cpp Outdated Show resolved Hide resolved
test/libsolidity/ASTJSONTest.cpp Outdated Show resolved Hide resolved
test/libsolidity/ASTJSONTest.cpp Outdated Show resolved Hide resolved
test/libsolidity/ASTJSONTest.cpp Outdated Show resolved Hide resolved
test/libsolidity/ASTJSONTest.cpp Outdated Show resolved Hide resolved
@wechman wechman force-pushed the unreliableAstJsonTests branch 4 times, most recently from 70383f5 to 09ce867 Compare February 25, 2022 06:45
@wechman wechman requested a review from Marenz February 25, 2022 09:19
@wechman wechman force-pushed the unreliableAstJsonTests branch 2 times, most recently from 3683b5a to e2d37a0 Compare March 4, 2022 13:26
@wechman
Copy link
Collaborator Author

wechman commented Mar 4, 2022

I squashed commits and rebased them on the top of the develop branch.
@Marenz @cameel @chriseth do you see anything that needs to be addressed before we merge?


if (m_variants.empty())
BOOST_THROW_EXCEPTION(runtime_error("Missing file with expected result for: \"" + _filename + "\"."));

ifstream file(_filename);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason why all the stuff starting from here cannot be done by TestCaseReader instead? Not that it's strongly related to the issue at hand, but still...

@ekpyron
Copy link
Member

ekpyron commented Mar 7, 2022

What will happen, if I add failAfter: Parsed to a test, but it still has the old expectation file?
Or conversely, what will happen if failAfter: Parsed is present, but no _parseOnly file is present?
It might in general help if the PR description explained the intended new logic.

To me it would seem that, ideally, the solidity source file fully determines what variants are expected with its settings and a run of isoltest will verify that the appropriate expectation files are there and only those - and error out specifically if the set of expectation files doesn't match... but from a quick glance, it looks like the PR runs variants based on which files are present?

But I may have missed some discussion on this.

@wechman
Copy link
Collaborator Author

wechman commented Mar 7, 2022

@ekpyron Yes, the idea was to run variants based on which files are present. I am not sure if we can depend on *.sol file only. In fail_after_parsing test we expect a compilation fail after parsing. But even so, in the second test variant, a result AST is enriched by "exportedSymbols". Do you think the second variant makes not sense?

@ekpyron
Copy link
Member

ekpyron commented Mar 7, 2022

@ekpyron Yes, the idea was to run variants based on which files are present. I am not sure if we can depend on *.sol file only. In fail_after_parsing test we expect a compilation fail after parsing. But even so, in the second test variant, a result AST is enriched by "exportedSymbols". Do you think the second variant makes not sense?

I don't think there is any way to make the compiler output an AST on the fail_after_parsing test without specifying --stop-after parsing (which will lead to the _parseOnly AST). So the second variant does not really make sense - it just tests some partial intermediate result that will never actually occur anywhere.

@wechman
Copy link
Collaborator Author

wechman commented Mar 7, 2022

Thank you for the quick response! It is all clear now. I will update code to validate the test variants based on the "failAfter" marker.

@wechman wechman force-pushed the unreliableAstJsonTests branch from fa0e9be to f3620b3 Compare March 7, 2022 13:21
@wechman
Copy link
Collaborator Author

wechman commented Mar 7, 2022

@ekpyron I updated PR with JSONs/variants validation. Please let me know if this is what you expected to see.

@wechman wechman force-pushed the unreliableAstJsonTests branch from 2b2a8ee to 4bd61f6 Compare March 7, 2022 17:12
@wechman wechman self-assigned this Mar 9, 2022
ekpyron
ekpyron previously approved these changes Mar 14, 2022
Copy link
Member

@ekpyron ekpyron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still wondering about #12696 (comment) - but we don't need to change this in the same PR, even if we want to change it, I guess.

Also I'd still consider always expecting and checking a parseOnly file, but arguably it's also fine to merely check it if it's there...

So since regardless of either of that, this PR is definitely an improvement, I'm approving.

@chriseth
Copy link
Contributor

Please squash

@wechman
Copy link
Collaborator Author

wechman commented Mar 14, 2022

Please squash

done

@chriseth chriseth merged commit 9ef590c into develop Mar 14, 2022
@chriseth chriseth deleted the unreliableAstJsonTests branch March 14, 2022 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AST JSON tests do not clear AST for parse-only test cases.
5 participants